﻿using Abp.Runtime.Validation;
using NetCore.Dtos;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;

namespace NetCore.Projects.Dtos
{
    public class AddProjectUserInputDto : BaseDto
    {
        public AddProjectUserInputDto()
        {
            UserIds = new List<long>();
        }

        /// <summary>
        /// 项目Id
        /// </summary>
        [Required]
        public int? ProjectId { get; set; }
        /// <summary>
        /// 用户Ids
        /// </summary>
        public List<long> UserIds { get; set; }

        public virtual void AddValidationErrors(CustomValidationContext context)
        {
            //throw new NotImplementedException();
            if (!UserIds.Any())
            {
                context.Results.Add(new ValidationResult("至少选中一个用户!"));
            }
        }
    }
}
